package msi.gama.display.java3d.renderingObject;

import javax.vecmath.Vector3f;

/**
 * minhvv, p18, IFI, TPE 01/2014 - 07/2014
 */

public class InfoObject implements IChangedObject {
	private Vector3f position = null;
	private boolean posChanged = false;

	private InfoObject buffer = null;

	public InfoObject(Vector3f position) {
		this.position = position;
	}

	public boolean isPositionChanged() {
		return true == this.posChanged;
	}

	public Vector3f getCurrentPosition() {
		return this.position;
	}

	/*
	 * FOR BUFFER DATA
	 */

	public void setNewData(Vector3f position) {
		this.buffer = new InfoObject(position);

		processChangeData();
		cleanBufferData();
	}

	@Override
	public void processChangeData() {
		_processChangePosition();
	}

	@Override
	public void cleanBufferData() {
		this.buffer = null;
	}

	private void _processChangePosition() {
		if (!this.position.equals(buffer.position)) {
			this.position = buffer.position;
			this.posChanged = true;
		} else {
			this.posChanged = false;
		}
	}

	public String toString() {
		return "pos: " + position.toString();
	}
}
